package com.gg.star.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.beanhelper.BeanHelper;
import com.gg.entity.Star;
import com.gg.entity.User;
import com.gg.star.service.StarService;

import base.BaseServlet;


@WebServlet("/star/AddStarServlet")
public class AddStarServlet extends BaseServlet {
	
	@Autowired
	private  StarService  starService;
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Star  star =    BeanHelper.getBean(request.getParameterMap(), Star.class);
		System.out.println(star+"-------");
		User  user  =  (User) request.getSession().getAttribute("user");
		String  uid =  user.getUid();
		star.setUid(uid);
		boolean   res =   starService.addStart(star);
		//如果添加关注成功
		if(res) {
			request.getSession().setAttribute("isStar", true);
		}
		
		response.setContentType("json/application;charset=utf-8");
		response.getWriter().print(res);
		
	}

}
